package com.rf.richfitwheel.sysbill.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rf.richfitwheel.common.utils.StringUtils;

import com.rf.richfitwheel.sysbill.dao.SysBillAccountMapper;
import com.rf.richfitwheel.sysbill.model.SysBillAccount;
import com.rf.richfitwheel.sysbill.service.SysBillAccountService;
import com.rf.richfitwheel.utils.PageJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wangTao
 * @since 2024-06-17
 */
@Service
public class SysBillAccountServiceImpl extends ServiceImpl<SysBillAccountMapper, SysBillAccount> implements SysBillAccountService {

    @Autowired
    private SysBillAccountMapper sysBillAccountMapper;
    @Override
    public PageJson pageJson(SysBillAccount sysBillAccount) {
        Page<SysBillAccount> page = new Page<>(sysBillAccount.getPageNum(), sysBillAccount.getPageSize());
        QueryWrapper<SysBillAccount> queryWrapper = new QueryWrapper<>();
        //单位名称
        if (StringUtils.isNotBlank(sysBillAccount.getUnitName())) {
            queryWrapper.like("unit_name",sysBillAccount.getUnitName());
        }
        //直联银行
        if (StringUtils.isNotBlank(sysBillAccount.getBankName())) {
            queryWrapper.like("bank_name",sysBillAccount.getBankName());
        }
        //票据账户
        if (StringUtils.isNotBlank(sysBillAccount.getBillAccount())) {
            queryWrapper.eq("bill_account",sysBillAccount.getBillAccount());
        }
        //直联状态
        if (StringUtils.isNotBlank(sysBillAccount.getBankStatus())) {
            queryWrapper.eq("bank_status",sysBillAccount.getBankStatus());
        }
        Page<SysBillAccount> pageData = sysBillAccountMapper.selectPage(page, queryWrapper);
        return PageJson.of(pageData);
    }
}
